package dailyTopic;

import java.util.Arrays;

/**
 * @author zhangmin
 * @create 2021-08-01 15:47
 */
public class kWeakestRows1337 {
    public int[] kWeakestRows(int[][] mat, int k) {
        int[] res=new int[k];
        int n=mat.length;
        //标记是否以及被排除
        int[] visited=new int[n];
        Arrays.fill(visited,0);
        int m=mat[0].length;
        int num=0;
        //按列开始排查
        for (int i = 0; i <m ; i++) {
            for (int j = 0; j <n ; j++) {
                if(visited[j]==0&&mat[j][i]==0){
                    System.out.println("j="+j);
                    System.out.println("i="+i);
                    visited[j]=1;
                    res[num]=j;
                    System.out.println("res"+num+"="+res[num]);
                    num++;
                }
                if (num>=k){
                    return res;
                }
            }
        }
        for (int i = 0; i <n ; i++) {
            if (visited[i]==0){
                res[num]=i;
                num++;
                if (num>=k){
                    break;
                }
            }
        }
        return res;
    }
    /*public static void main(String[] args) {
        //int[] nums1=new int[]{3,5,4,2,4,6};
        //int[] nums2=new int[]{2,3,5};
        int[][] mat=new int[][]{{1,0},{1,0},{1,0},{1,1}};
       // String columnTitle = "AB";
        dailyTopic.kWeakestRows1337 object=new dailyTopic.kWeakestRows1337();
        int[] res=object.kWeakestRows(mat,4);
        for (int r:res) {
            System.out.println(r);
        }

    }*/
}
